package duoxiancheng.Timer;

import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Timer;
import java.util.TimerTask;

public class Timertest01 {
    public static void main(String[] args) {
        Timer timer = new Timer();
        //执行安排
        //timer.schedule(new MyTask(),1000);//执行任务一次
        //timer.schedule(new MyTask(),1000,1000);//每隔1s执行一次
        Calendar cal = new GregorianCalendar(2019,1,14,17,53,40);
        timer.schedule(new MyTask(),cal.getTime());//指定时间执行

    }
}

class MyTask extends TimerTask{
    @Override
    public void run() {
        for (int i = 0; i <10 ; i++) {
            System.out.println("你好");
        }
        System.out.println("---------end----------");
    }
}